import Assert from "../Assert";
import { post, postUpload,get } from "/@/request/http";

export default class HttpReqApi {


    static async editLoc(name:string,seriesName:string,lng:string,lat:string)
    {
        let res = await get("/Shusanyaosu/editLoc",{name,seriesName,lng,lat});
        return this.checkResult(res);
    }
    static async editLocWuzi(name:string,seriesName:string,lng:string,lat:string)
    {
        let res = await get("/zhanbeiwuzi/editLoc",{name,seriesName,lng,lat});
        return this.checkResult(res);
    }

    static async editLocRenFang(name:string,seriesName:string,lng:string,lat:string)
    {
        let res = await get("/zhihuijigou/editLoc",{name,seriesName,lng,lat});
        return this.checkResult(res);
    }
    static async editLocDuiwu(name:string,seriesName:string,lng:string,lat:string)
    {
        let res = await get("/zhuanyeduiwu/editLoc",{name,seriesName,lng,lat});
        return this.checkResult(res);
    }


    static async upload(form){
        let res = await postUpload("/equip/upload",form);
        return this.checkResult(res);
    }

    static async getEquips(){
       let res = await get("/equip/getEquips",{});
       return this.checkResult(res);
    }

    static async updateEquip(data){
        let res = await post("/equip/updateEquip",data,null);
        return this.checkResult(res);
    }
    

    static async addHelpscheme(data){
        let res = await post("/helpscheme/add",data,null);
        return this.checkResult(res);
    }

    static async updateHelpscheme(data){
        let res = await post("/helpscheme/updateOne",data,null);
        return this.checkResult(res);
    }

    static async getHelpschemes(data){
        let res = await post("/helpscheme/getList",data,true);
        return this.checkResult(res);
    }
    static async getHelpschemesAll(){
        let res = await get("/helpscheme/getAll",{});
        return this.checkResult(res);
    }

    static async delHelpSchemes(data){
        let res = await get("/helpscheme/delOne",data);
       return this.checkResult(res);
    }
    static async getHelpschemeOne(data){
        let res = await get("/helpscheme/getOne",data);
       return this.checkResult(res);
    }

    static async getEconomicTargets(){
        let res = await get("/Shusanyaosu/getList",{});
        return this.checkResult(res);
    }
    static async getEconomicTargetOne(id:string){
        let res = await get("/Shusanyaosu/getOne",{id});
        return this.checkResult(res);
    }

    static async getZhanbeiwuzi(){
        let res = await get("/zhanbeiwuzi/getAll",{});
        return this.checkResult(res);
    }
    static async getZhanbeiwuziOne(id:string){
        let res = await get("/zhanbeiwuzi/getOne",{id});
        return this.checkResult(res);
    }
    static async getZhuanyeduiwu(){
        let res = await get("/zhuanyeduiwu/getAll",{});
        return this.checkResult(res);
    }
    static async getZhuanyeduiwuOne(id:string){
        let res = await get("/zhuanyeduiwu/getOne",{id});
        return this.checkResult(res);
    }
    static async getZhihuijigou(){
        let res = await get("/zhihuijigou/getAll",{});
        return this.checkResult(res);
    }
    static async getZhihuijigouOne(id:string){
        let res = await get("/zhihuijigou/getOne",{id});
        return this.checkResult(res);
    }

    static async uploadword(form){
        let res = await postUpload("/equip/uploadWord",form);
        return this.checkResult(res);
    }
    

    private static async checkResult(res:any){
        return new Promise((resolve)=>{
            if(typeof res == "string")
            {
                if(res == "success")
                {
                    resolve(res);
                    return;
                }
                Assert.isFalse(true,res+"");
                return;
            }
            resolve(res);
        });
    }

}